<?

class Video {
	private $videoid;
	private $matchid;
	private $thanks;
	private $extension;
	private $path;
	private $size;
	private $length;
	
	// CONTRACT: __construct : number -> Event
	// PURPOSE
	// __construct is the auto-called function that builds a new Event. It takes a $eventid and returns the Event object for the corresponding event in the database.
	
	function __construct($eventid) {
		//ensure valid input
		if (!is_numeric($eventid)) { //it's not an eventid, it's a string pointing to a video file?
			if (file_exists($eventid)) {
				$this->archaicConstruct($eventid);
			}
		} else {
			echo "Failed Video Instantiation";
			//setup and run query
			// $eventinfo_query_filter = "SELECT * FROM events WHERE eventid='$eventid' LIMIT 1";
			// $eventinfo_query = mysql_query($eventinfo_query_filter);
			// if (mysql_num_rows($eventinfo_query) < 1) {
				// throw_error("No event found for eventid for Event Object instantiation. Given " . $eventid);
			// }
			// //copy into object
			// $eventinfo = mysql_fetch_array($eventinfo_query);
			// $this->eventid 		= $eventid;
			// $this->name 		= $eventinfo["name"];
			// $this->shortname 	= $eventinfo["shortname"];
			// $this->eventshort 	= $eventinfo["eventshort"];
			// $this->year 		= $eventinfo["year"];
			// $this->week 		= $eventinfo["week"];
			// $this->thanks 		= $eventinfo["thanks"];
			// $this->location 	= $eventinfo["location"];
			// $this->latlong 		= array($eventinfo["lat"],$eventinfo["long"]);
			// $this->website 		= $eventinfo["website"];
			// $this->official 	= $eventinfo["official"];
		}
	}
	
	function archaicConstruct($vidpath) {
		$this->videoid = Null;
		$this->matchid = Null;
		$this->thanks = Null;
		$this->extension = substr($vidpath,-3,3);
		$this->path = $vidpath;
		$this->size = floor(filesize($vidpath) / 1048576);
		$this->length = Null;
	}
	
	function getPath() {
		return $this->path;
	}
	function getSize() {
		return $this->size;
	}
	function getExtension() {
		return $this->extension;
	}

}